home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Archives / GNU / GNUPLOTsrc.lha / term / emxvga.trm < prev    next >
Encoding:
Text File  |  1996-01-22  |  7.3 KB  |  296 lines

  1. /* GNUPLOT - emxvga.trm */
  2. /*
  3.  * Copyright (C) 1994
  4.  *
  5.  * Permission to use, copy, and distribute this software and its
  6.  * documentation for any purpose with or without fee is hereby granted, 
  7.  * provided that the above copyright notice appear in all copies and 
  8.  * that both that copyright notice and this permission notice appear 
  9.  * in supporting documentation.
  10.  *
  11.  * Permission to modify the software is granted, but not the right to
  12.  * distribute the modified code.  Modifications are to be distributed 
  13.  * as patches to released version.
  14.  *
  15.  * This software  is provided "as is" without express or implied warranty.
  16.  *
  17.  * This file is included by ../term.c.
  18.  *
  19.  * This terminal driver supports:
  20.  *  SVGA 1024x768x256 for PC's running DOS or OS/2
  21.  *
  22.  * AUTHOR
  23.  *   David J. Liu (liu@phri.nyu.edu)
  24.  */
  25.  
  26. /*
  27.  * Compile with GCC (emx) with VESA and SVGAKIT maintained by
  28.  * Johannes Martin (JMARTIN@GOOFY.ZDV.UNI-MAINZ.DE)
  29.  * with additions by David J. Liu (liu@phri.nyu.edu)
  30.  * supports VESA, Trident, Cirrus, ET4000, WD and S3.
  31.  */
  32.  
  33. /* 
  34.  * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
  35.  */
  36.  
  37. #ifndef GOT_DRIVER_H
  38. #include "driver.h"
  39. #endif
  40.  
  41. #ifdef TERM_REGISTER
  42. #ifdef EMXVESA
  43. register_term(vesa)
  44. #endif /* VESA */
  45. register_term(vgal)
  46. register_term(emxvga)
  47. #endif
  48.  
  49. #ifdef TERM_PROTO
  50. TERM_PUBLIC void EMXVGA_init __P((void));
  51. TERM_PUBLIC void EMXVGA_reset __P((void));
  52. TERM_PUBLIC void EMXVGA_text __P((void));
  53. TERM_PUBLIC void EMXVGA_graphics __P((void));
  54. TERM_PUBLIC void EMXVGA_linetype __P((int));
  55. TERM_PUBLIC void EMXVGA_move __P((unsigned int, unsigned int));
  56. TERM_PUBLIC void EMXVGA_vector __P((unsigned int, unsigned int));
  57. TERM_PUBLIC int EMXVGA_text_angle __P((int));
  58. TERM_PUBLIC void EMXVGA_put_text __P((unsigned int, unsigned int, char *));
  59. #define EMXVGA_VCHAR 8
  60. #define EMXVGA_HCHAR 8
  61. #define EMXVGA_VTIC 4
  62. #define EMXVGA_HTIC 4
  63. #define EMXVGA_XMAX 0 /* These two entries are just place holders. */
  64. #define EMXVGA_YMAX 0 /* The actual values will be filled in init. */
  65.  
  66. #ifdef EMXVESA
  67. TERM_PUBLIC void EMXVESA_options __P((void));
  68. TERM_PUBLIC void EMXVESA_init __P((void));
  69. TERM_PUBLIC void EMXVESA_graphics __P((void));
  70. TERM_PUBLIC void EMXVESA_text __P((void));
  71. TERM_PUBLIC void EMXVESA_reset __P((void));
  72. #endif
  73.  
  74. #endif /* TERM_PROTO */
  75.  
  76. #ifndef TERM_PROTO_ONLY
  77. #ifdef TERM_BODY
  78. #include <vesa.h>
  79. #include <graph.h>
  80. #include <conio.h> /* for getch()        -SB */
  81.  
  82. /*
  83.  * Some versions of graph.h (e.g. jmgraph.h) define RIGHT to be 0
  84.  * colliding with enum JUSTIFY. We don't need this define anyway,
  85.  * just undef it.            -SB
  86.  */
  87. #ifdef RIGHT
  88. #undef RIGHT
  89. #endif
  90.  
  91. static int EMXVGA_vmode=G640x480x256 ; /* default mode */
  92. static int vgacolor[]={7,8,2,3,4,5,9,14,12,15,13,10,11,1,6} ;
  93. static int graphics_on=FALSE ;
  94. int startx,starty,lasty ;
  95. int EMXVGA_angle,EMXVGA_color ;
  96. char EMXVGA_chr ;
  97.  
  98. TERM_PUBLIC void EMXVGA_init ()
  99. {
  100.   if (!g_mode(EMXVGA_vmode))
  101.     { fprintf (stderr,"Unable to initiate graphics.\n") ; return; }
  102.   term->xmax=g_xsize ;
  103.   term->ymax=g_ysize ;
  104.   lasty=g_ysize-1 ;
  105. }
  106.  
  107. TERM_PUBLIC void EMXVGA_reset ()
  108. {
  109.   g_mode (GTEXT) ; graphics_on=FALSE ;
  110. }
  111.  
  112. TERM_PUBLIC void EMXVGA_text ()
  113. {
  114.   if (graphics_on)
  115.     { VesaGetCharacter (&EMXVGA_chr) ; g_mode (GTEXT) ; graphics_on=FALSE ; }
  116. }
  117.  
  118. TERM_PUBLIC void EMXVGA_graphics ()
  119. {
  120.   if (!graphics_on) { g_mode (EMXVGA_vmode) ; graphics_on=TRUE ; }
  121. }
  122.  
  123. TERM_PUBLIC void EMXVGA_linetype (linetype)
  124.   int linetype;
  125. {
  126.   EMXVGA_color=vgacolor[(linetype%13)+2] ;
  127. }
  128.  
  129. TERM_PUBLIC void EMXVGA_move (x,y)
  130.   unsigned int x,y;
  131. {
  132.   startx=x ; starty=y ;
  133. }
  134.  
  135. TERM_PUBLIC void EMXVGA_vector (x,y)
  136.   unsigned int x,y;
  137. {
  138.   g_line (startx,lasty-starty,x,lasty-y,EMXVGA_color) ;
  139.   startx=x ; starty=y ;
  140. }
  141.  
  142. TERM_PUBLIC int EMXVGA_text_angle (ang)
  143.   int ang ;
  144. {
  145.   EMXVGA_angle=ang*90 ;
  146.   return (TRUE) ;
  147. }
  148.  
  149. TERM_PUBLIC void EMXVGA_put_text (x,y,str)
  150.   unsigned int x,y ;
  151.   char *str ;
  152. {
  153.   g_string (x,lasty-y-3,EMXVGA_color,EMXVGA_angle,str) ;
  154. }
  155.  
  156. #ifdef EMXVESA
  157. int emx_vesamode = G640x480x256;
  158. int emx_xlast, emx_ylast;
  159.  
  160. TERM_PUBLIC void EMXVESA_options()
  161. {
  162.     if (!END_OF_COMMAND) {
  163.         if (almost_equals(c_token,"d$efault")) {
  164.             emx_vesamode = G640x480x256;
  165.             c_token++;
  166.         }
  167.     }
  168.  
  169.     if (!END_OF_COMMAND) {
  170.         /* We have a vesa mode specified */
  171.         struct value a;
  172.         emx_vesamode = (int)real(const_express(&a));
  173.     }
  174.  
  175.     sprintf(term_options,"%d",emx_vesamode);
  176. }
  177.  
  178. TERM_PUBLIC void EMXVESA_init()
  179. {
  180.     if (!g_mode(emx_vesamode))
  181.         int_error("Couldn't select graphics mode",NO_CARET);
  182.     emx_xlast = g_xsize - 1;
  183.         term->xmax = emx_xlast + 1;
  184.     emx_ylast = g_ysize - 1;
  185.         term->ymax = emx_ylast + 1;
  186.     g_mode(GTEXT);
  187. }
  188.  
  189. TERM_PUBLIC void EMXVESA_graphics()
  190. {
  191.     g_mode(emx_vesamode);
  192. }
  193.  
  194. TERM_PUBLIC void EMXVESA_text()
  195. {
  196. int ch;
  197.     ch = getch();
  198.     g_mode(GTEXT);
  199.     if (ch == 3)
  200.         int_error("Interrupt",NO_CARET);
  201. }
  202.  
  203. TERM_PUBLIC void EMXVESA_reset()
  204. {
  205. }
  206. #endif /* VESA */
  207.  
  208. #endif /* TERM_BODY */
  209.  
  210. #ifdef TERM_TABLE
  211.  
  212. #ifdef EMXVESA
  213. TERM_TABLE_START(vesa_driver)
  214.     "vesa", "IBM PC/Clone with VESA SVGA graphics board [vesa mode]",
  215.        EMXVGA_XMAX, EMXVGA_YMAX, EMXVGA_VCHAR, EMXVGA_HCHAR,
  216.        EMXVGA_VTIC, EMXVGA_HTIC, EMXVESA_options, EMXVESA_init, EMXVESA_reset,
  217.        EMXVESA_text, null_scale, EMXVESA_graphics, EMXVGA_move, EMXVGA_vector,
  218.        EMXVGA_linetype, EMXVGA_put_text, EMXVGA_text_angle, 
  219.        null_justify_text, do_point, do_arrow, set_font_null
  220. TERM_TABLE_END(vesa_driver)
  221.  
  222. #undef LAST_TERM
  223. #define LAST_TERM vesa_driver
  224. #endif /* VESA */
  225.  
  226. TERM_TABLE_START(vgal_driver)
  227.     "vgal", "IBM PC/Clone with VGA graphics board",
  228.        EMXVGA_XMAX, EMXVGA_YMAX, EMXVGA_VCHAR, EMXVGA_HCHAR,
  229.        EMXVGA_VTIC, EMXVGA_HTIC, options_null, EMXVGA_init, EMXVGA_reset,
  230.        EMXVGA_text, null_scale, EMXVGA_graphics, EMXVGA_move, EMXVGA_vector,
  231.        EMXVGA_linetype, EMXVGA_put_text, EMXVGA_text_angle, 
  232.        null_justify_text, do_point, do_arrow, set_font_null
  233. TERM_TABLE_END(vgal_driver)
  234.  
  235. #undef LAST_TERM
  236. #define LAST_TERM vgal_driver
  237.  
  238. TERM_TABLE_START(emxvga_driver)
  239.       "emxvga", "PC with SuperVGA running DOS or OS/2",
  240.            EMXVGA_XMAX, EMXVGA_YMAX, EMXVGA_VCHAR, EMXVGA_HCHAR,
  241.            EMXVGA_VTIC, EMXVGA_HTIC, options_null, EMXVGA_init, EMXVGA_reset,
  242.            EMXVGA_text, null_scale, EMXVGA_graphics, EMXVGA_move,
  243.        EMXVGA_vector, EMXVGA_linetype, EMXVGA_put_text, EMXVGA_text_angle,
  244.            null_justify_text, do_point, do_arrow, set_font_null
  245. TERM_TABLE_END(emxvga_driver)
  246.  
  247. #undef LAST_TERM
  248. #define LAST_TERM emxvga_driver
  249.  
  250. #endif /* TERM_TABLE */
  251. #endif /* TERM_PROTO_ONLY */
  252.  
  253. #ifdef EMXVESA
  254. /*
  255.  * NAME: vesa 
  256.  *
  257.  * OPTIONS: mode = vesa-mode (default G640x480x256)
  258.  *
  259.  * SUPPORTS: PC with vesa SVGA graphics board.
  260.  *
  261.  * Further Info: Used when compiled with emx-gcc (both DOS and OS/2).
  262.  *         Needs VESA and SVGAKIT maintained by
  263.  *         Johannes Martin (JMARTIN@GOOFY.ZDV.UNI-MAINZ.DE)
  264.  *         with additions by David J. Liu (liu@phri.nyu.edu).
  265.  *
  266.  */
  267. #endif /* EMXVESA */
  268.  
  269. /*
  270.  * NAME: vgal
  271.  *
  272.  * OPTIONS: none
  273.  *
  274.  * SUPPORTS: PC with VGA graphics board
  275.  *
  276.  * Further Info: Used when compiled with emx-gcc (both DOS and OS/2).
  277.  *         Needs VESA and SVGAKIT maintained by
  278.  *         Johannes Martin (JMARTIN@GOOFY.ZDV.UNI-MAINZ.DE)
  279.  *         with additions by David J. Liu (liu@phri.nyu.edu).
  280.  *
  281.  */
  282.  
  283. /*
  284.  * NAME: emxvga
  285.  *
  286.  * OPTIONS: none
  287.  *
  288.  * SUPPORTS: PC with SVGA graphics board
  289.  *
  290.  * Further Info: Used when compiled with emx-gcc (both DOS and OS/2).
  291.  *         Needs VESA and SVGAKIT maintained by
  292.  *         Johannes Martin (JMARTIN@GOOFY.ZDV.UNI-MAINZ.DE)
  293.  *         with additions by David J. Liu (liu@phri.nyu.edu).
  294.  *
  295.  */
  296.